package com.mike.swt.table;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.jface.viewers.TreeViewer;

import com.mike.swt.table.model.GameWorld;

public class MyTreeViewer {

	protected Shell shell;
	private TreeViewer treeViewer;

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			GameWorld.getInstance().initWorld();
			MyTreeViewer window = new MyTreeViewer();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setSize(450, 300);
		shell.setText("Team Editor");
		shell.setLayout(new FillLayout(SWT.HORIZONTAL));
		{
			Composite composite = new Composite(shell, SWT.NONE);
			composite.setLayout(new FillLayout(SWT.HORIZONTAL));
			{
				treeViewer = new TreeViewer(composite, SWT.BORDER);
				treeViewer.setContentProvider(new MyTreeContentProvider());
				treeViewer.setLabelProvider(new MyTreeLabelProvider());
				treeViewer.setInput("GameWorld");
			}
		}

	}
}
